<?php
	/*
		PandaForum: PHP Forum Engine
		
		Jesse Gill, 0108377707
	*/
	
	class Structure
	{
		// list of pages for the navbar
		private $pagelist = array('Index' => 'index.php', 'Members' => 'members.php', 'Register' => 'register.php');
		private $acpnav = array('ACP' => 'acp.php', 'Forums' => 'acp-forums.php', 'Groups' => 'acp-groups.php', 'Ranks' => 'acp-ranks.php');
		private $ucpnav = array('UCP' => 'ucp.php', 'Friends/Enemies' => 'ucp-friendenemy.php', 'Groups' => 'ucp-groups.php', 'Ranks' => 'ucp-ranks.php');
		private $usermenulist = array('ACP' => 'acp.php', 'UCP' => 'ucp.php', 'Logout' => 'javascript:ajax_logout();');
		
		private $name = ''; // current page's name
		
		function __construct($name)
		{
			$this->name = $name;
		}
		
		function __destruct()
		{
			
		}
		
		function print_header($curUser)
		{
?>
	<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>

	<html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<meta name='author' content='Pandepic Software' />
			<meta http-equiv='Content-Type' content='text/html;charset=utf-8' />
			<link href='src/css/main.css' rel='stylesheet' type='text/css' />
			
			<title> PandaForum - <?php echo $this->name; ?> </title>
			
			<script type="text/javascript" src="src/js/ajax_functions_main.js"></script>
		</head>
		
		<body>
			<div id="page_container">
				<div id="header"> </div>
				
				<?php $this->print_navbar(); ?>
				
				<div style="clear: both;"> </div>
				
				<?php $this->print_userbar($curUser); ?>
				
				<div style="clear: both;"> </div>
				
				<div id="current_path">
				
				</div>
				
				<div style="clear: both;"> </div>
				
				<div id="content">
<?php
		}
		
		function print_footer()
		{
?>
				</div> <!--end content-->
			</div> <!--end page_container-->
		</body>
	</html>
<?php
		}
		
		function print_navbar()
		{
?>
			<div id="navbar">
				<?php
					foreach ($this->pagelist as $pagename => $pagelink)
					{
						$this->print_navlink($pagename, $pagelink);
					}
				?>
			</div>
<?php
		}
		
		function print_navlink($name, $href)
		{
?>
			<a <?php if ($name == $this->name) { echo " class='selected' "; } ?> href="<?php echo $href; ?>"> <?php echo $name; ?> </a>
<?php
		}
		
		function print_userbar($curUser)
		{
?>
			<div id="userbar">
				<?php
					if ($curUser->isOnline == true)
					{
						$this->print_usermenu_box($curUser->data_array['username']);
					}
					else
					{
						$this->print_login_box();
					}
				?>
			</div>
<?php
		}
		
		function print_login_box()
		{
?>
			<div id='loginbox'>
				<form name='loginForm' method='post' action='javascript:ajax_login();'>
					Username: <input type='text' name='username' />
					<br />
					Password: <input type='password' name='password' />
					<input type='submit' value='Login' />
				</form>
			</div>
<?php
		}
		
		function print_usermenu_box($username)
		{
?>
			<p>Welcome, <?php echo $username; ?>.</p>
			<?php
				foreach ($this->usermenulist as $listname => $listlink)
				{
			?>
					<a href='<?php echo $listlink; ?>'><?php echo $listname; ?></a>
			<?php
				}
			?>
<?php
		}
		
		function print_acp_nav()
		{
?>
			<div id="acp_nav">
				<?php
					foreach ($this->acpnav as $pagename => $pagelink)
					{
						$this->print_navlink($pagename, $pagelink);
					}
				?>
			</div>
<?php
		}
		
		function print_ucp_nav()
		{
?>
			<div id="acp_nav">
				<?php
					foreach ($this->ucpnav as $pagename => $pagelink)
					{
						$this->print_navlink($pagename, $pagelink);
					}
				?>
			</div>
<?php
		}
	}
?>
